package
{
	import capricornus.components.ComponentsManager;
	import capricornus.events.StageEvent;
	import capricornus.core.StageManager;
	import capricornus.net.NetWorkManager;
	
	import components.alert.Alert;
	import components.editbar.EditBarController;
	import components.map.MapController;
	import components.toolbar.ToolBarController;
	import components.utils.FocusManager;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.utils.setTimeout;

	public class MapEditor extends Sprite
	{
		private var _toolbarController:ToolBarController;
		private var _mapController:MapController;
		
		public function MapEditor()
		{
			init();
		}
		
		private function init():void
		{
			StageManager.instance.initialize( stage );
			NetWorkManager.instance.initialize();
			ComponentsManager.instance;
			FocusManager.instance;
			
			createComponents();
			
			onResize(null);
			StageManager.instance.addEventListener( StageEvent.RESIZE, onResize, false, 0, true );
			
			this.tabChildren = false;
			this.tabEnabled = false;
			
			setTimeout( create, 1000 );
		}
		
		private function create():void
		{
			/*MapController.instance.createNewMap( 4000, 2000, 40, 20 );
			
			Alert.show( "sdfsdfsdfsdfsdf" );*/
		}
		
		private function createComponents():void
		{
			_toolbarController = new ToolBarController();
			_mapController = new MapController();
			new EditBarController();
		}
		
		private function onResize( e:Event ):void
		{
			graphics.clear();
			
			graphics.beginFill(0,0.3);
			graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
			graphics.endFill();
		}
	}
}